package io.gitee.bluemiaomiao.dataanalyzebackend.controller;

import com.alibaba.fastjson.JSONObject;
import io.gitee.bluemiaomiao.dataanalyzebackend.domian.shop.ShopVIpDto;
import io.gitee.bluemiaomiao.dataanalyzebackend.domian.shop.number;
import io.gitee.bluemiaomiao.dataanalyzebackend.repos.ShopMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.text.ParseException;
import java.util.List;

/**
 * @author Administrator
 * @description 单会员分析请求
 */
@RestController
@RequestMapping(value = "/cumer")
public class OneVipAnalysisController {

  @Autowired private ShopMapper shopMapper;

  @ResponseBody
  @RequestMapping(value = "/shop_only", method = RequestMethod.POST)
  public String shop_only(
      @RequestParam("befor") String befor,
      @RequestParam("lafter") String after,
      @RequestParam("shop_name") String shop_name)
      throws ParseException {

    List<ShopVIpDto> a = shopMapper.cx_only_shop(befor, after, shop_name);
    String json = JSONObject.toJSONString(a);
    return json;
  }

  @ResponseBody
  @RequestMapping(value = "/pie", method = RequestMethod.POST)
  public String shop_pie(
      @RequestParam("befor") String name,
      @RequestParam("lafter") String mm,
      @RequestParam("phone") String phone,
      @RequestParam("shop_name") String shop_name) {
    List<number> a = shopMapper.cx_shop_pie(phone, name, mm, shop_name);
    String json = JSONObject.toJSONString(a);
    return json;
  }

  @ResponseBody
  @RequestMapping(value = "/time", method = RequestMethod.POST)
  public String shop_time(
      @RequestParam("befor") String befor,
      @RequestParam("lafter") String after,
      @RequestParam("phone") String phone,
      @RequestParam("shop_name") String shop_name,
      @RequestParam("VeLineId") String VeLineId)
      throws ParseException {
    List<number> a = shopMapper.cx_shop_time(phone, befor, after, shop_name, VeLineId);
    String json = JSONObject.toJSONString(a);
    return json;
  }
}
